package com.hsl.housaileibot001.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hsl.housaileibot001.model.RefreshToken;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;

/**
 * Refresh Token Mapper 接口
 */
@Mapper
public interface RefreshTokenMapper extends BaseMapper<RefreshToken> {

    /**
     * 根据token查找RefreshToken
     *
     * @param token token值
     * @return RefreshToken
     */
    RefreshToken findByToken(@Param("token") String token);

    /**
     * 删除过期的RefreshToken
     *
     * @param now 当前时间
     * @return 删除的数量
     */
    int deleteExpiredTokens(@Param("now") LocalDateTime now);

    /**
     * 根据用户ID删除所有RefreshToken
     *
     * @param userId 用户ID
     * @return 删除的数量
     */
    int deleteByUserId(@Param("userId") Long userId);
}

